import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '',
    redirect: '/home'
  },
  {
    path: '/home',
    component: () => import('../views/home/Home.vue'),
    children: [
      {
        path: '',
        redirect: 'pop'
      },
      {
        path: 'pop',
        component: () => import('../views/home/children/Home-pop.vue')
      },
      {
        path: 'new',
        component: () => import('../views/home/children/Home-new.vue')
      },
      {
        path: 'sell',
        component: () => import('../views/home/children/Home-sell.vue')
      },
      {
        path: '*',
        redirect: 'pop'
      }
    ]
  },
  {
    path: '/category',
    component: () => import('../views/category/Category.vue')
  },
  {
    path: '/cart',
    component: () => import('../views/cart/Cart.vue')
  },
  {
    path: '/profile',
    component: () => import('../views/profile/Profile.vue')
  },
  {
    path: '/detail/:iid',
    component: () => import('../views/detail/Detail.vue')
  },
  {
    path: '*',
    redirect: '/home'
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
